package bitcarve.hydra.core.track.core
{
	import bitcarve.hydra.core.time.TimePoint;
	
	import flash.events.EventDispatcher;

	public class Track extends EventDispatcher implements ITrack
	{
		
		private var _childTracks:Array;
		private var _name:String;
		private var _startTime:TimePoint;
		private var _endTime:TimePoint;
		private var _index:int = 0;
		
		public function Track(name:String , start:int = 0, end:int = 0)
		{
			_name = name;
			_startTime = new TimePoint(start);
			_endTime = new TimePoint(end);
		}
		
		public function get name():String
		{
			return _name;
		}
		
		public function set name(value:String):void
		{
			_name = value;
		}
		
		public function get startTime() : TimePoint
		{
			return _startTime;
		}
		
		public function set startTime( value : TimePoint ) : void
		{
			_startTime = value;
		}
		
		public function get endTime() : TimePoint
		{
			return _endTime;
		}
		
		public function set endTime ( value : TimePoint ) : void
		{
			_endTime = value;
		}

		public function toXML():XML
		{
			return null;
		}
		
		public function get childTracks():Array
		{
			return _childTracks;
		}
		
		public function get row():int
		{
			return _index;
		}
		
		public function set row(value:int):void
		{
			_index = value;
		}
		
		public function loadXML(xml:XMLList):void
		{
		}
		
		public function addChildTrack(track:ITrack):void
		{
			if(_childTracks == null)
			{
				_childTracks = new Array();
			}
			_childTracks.push(track);
			track.row = _childTracks.indexOf(track);
		}
			
		
	}
}